package com.ourteam.product.api;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ourteam.frame.controller.AbstractCRUDServiceController;
import com.ourteam.product.ui.dao.ProductUIPageDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUIPageBean;
import com.ourteam.product.ui.service.IProductUIService;
import com.ourteam.product.ui.service.ProductUIServiceFactory;

@Controller
@RequestMapping("/api/PRODUCT/UI/ProductUIPage")
public class ProductUIPageAPI
		extends AbstractCRUDServiceController<ProductUIPageDAOQueryBean, ProductUIPageSearchModel, ProductUIPageBean> {

	private static final IProductUIService PRODUCT_UI_SERVICE = ProductUIServiceFactory.getProductUIService();

	@Override
	protected ProductUIPageDAOQueryBean newQueryBean() {
		return new ProductUIPageDAOQueryBean();
	}

	@Override
	protected int queryCount(ProductUIPageDAOQueryBean queryBean) throws Exception {
		return PRODUCT_UI_SERVICE.queryProductUIPageCount(queryBean);
	}

	@Override
	protected ProductUIPageBean[] queryData(ProductUIPageDAOQueryBean queryBean) throws Exception {
		return PRODUCT_UI_SERVICE.queryProductUIPages(queryBean);
	}

	@Override
	protected void deleteData(long[] ids) throws Exception {
		PRODUCT_UI_SERVICE.deleteProductUIPages(ids);
	}

	@Override
	protected ProductUIPageBean getDataById(long id) throws Exception {
		return PRODUCT_UI_SERVICE.getProductUIPageById(id);
	}

	@Override
	protected void saveData(ProductUIPageBean dataBean) throws Exception {
		if (dataBean.getId() == 0) {
			PRODUCT_UI_SERVICE.addNewProductUIPage(dataBean);
		} else {
			PRODUCT_UI_SERVICE.modifyProductUIPage(dataBean);
		}
	}

}
